package com.xiaoshuidi.cloud.module.guanwang.service;

import com.fasterxml.jackson.annotation.JsonTypeInfo;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
import java.util.Set;

@JsonTypeInfo(
    use = JsonTypeInfo.Id.CLASS
)
public interface GuanWangConfiguration {
    Set<ConstraintViolation<GuanWangConfiguration>> verifyParam(Validator validator);

    default void validate(Validator validator) {
        Set<ConstraintViolation<GuanWangConfiguration>> violations = this.verifyParam(validator);
        if (!violations.isEmpty()) {
            throw new ConstraintViolationException(violations);
        }
    }
}
